{include file="common/comm_header" /}

<body>
<div class="x-body layui-anim layui-anim-up">
    <form class="layui-form">
        <input type="hidden" name="repay_id" value="{$one_data.com_id}">
        <div class="layui-form-item">
            <label for="L_com_title" class="layui-form-label">
                留言昵称：
            </label>
            <div class="layui-input-block">
                <input style="border-style: none;" type="text" id="L_com_title" readonly="readonly" value="{$one_data.com_title}" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label for="L_com_content" class="layui-form-label">
                留言内容：
            </label>
            <div class="layui-input-block">
                <textarea style="resize: none;" readonly="readonly"  id="L_com_content" placeholder="客户端的留言~" class="layui-textarea">{$one_data.com_content}</textarea>
            </div>
        </div>

        <div class="layui-form-item">
            <label for="L_repay_content" class="layui-form-label">
                回复内容：
            </label>
            <div class="layui-input-block">
                <textarea style="resize: none;"  id="L_repay_content" name="repay_content" placeholder="您的回复" class="layui-textarea"></textarea>
            </div>
        </div>

        <!--提交按钮-->
        <div class="layui-form-item">
            <label for="L_repay_content" class="layui-form-label">
            </label>
            <button id="addAssort"  class="layui-btn" lay-filter="web-add" lay-submit="">
                回复
            </button>
        </div>
    </form>
</div>
<script type="text/javascript" src="/static/common/js/jquery.min.js"></script>
<script type="text/javascript" src="/static/admin//lib/layui/layui.js" charset="utf-8"></script>
<script type="text/javascript" src="/static/admin//js/xadmin.js"></script>
<!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
<!--[if lt IE 9]>
<script src="/static/common/js/html5.min.js"></script>
<script src="/static/common/js/respond.min.js"></script>
<![endif]-->
<script>
    layui.use(['form','layer'], function(){
        $ = layui.jquery;
        var form = layui.form
                ,layer = layui.layer;

        //自定义验证规则
        form.verify({
            repay_content: function(value){
                var valLen = value.length;
                if(valLen < 1){
                    return '回复写点东西吧';
                }
                if(valLen >220){
                    return '您的回复也太长了吧，不要超过220个字符';
                }
            }
        });

        //监听提交
        form.on('submit(web-add)', function(data){
            ///提交回复
            $('#addAssort').attr('disabled',true);
            $.ajax({
                url:'/{$Think.ADMIN_ROUT_PREFIX}/leave-reply/'+Math.random(),
                timeout : 3000,
                type : 'post',
                data :{repay_id:data.field.repay_id,repay_content:data.field.repay_content},
                async: false,
                dataType:'json',
                success:function(data){
                    var testJson = $.parseJSON(data);
                    if(testJson.status == 0){
                        layer.alert(testJson.msg, {
                            icon: 6,
                            time: 1000,
                            closeBtn:0,
                            end:function () {
                                // 获得frame索引
                                var index = parent.layer.getFrameIndex(window.name);
                                //关闭当前frame
                                parent.layer.close(index);
                            }
                        });
                    }else if(testJson.status == 2){
                        layer.alert(testJson.msg, {
                            icon: 5,
                            time: 2000
                        });
                        $('#addAssort').attr('disabled',false);
                        return false;
                    }else{
                        layer.alert('出现异常', {
                            icon: 5,
                            time: 2000
                        });
                        $('#addAssort').attr('disabled',false);
                        return false;
                    }
                },
                error:function(){
                    layer.alert('出现异常，建议刷新页面。', {
                        icon: 5,
                        time: 2000
                    });
                    $('#addAssort').attr('disabled',false);
                    return false;
                }
            });

            return false;
        });


    });
</script>
</body>

{include file="common/comm_bottom" /}